package com.huya.controller.user;


import com.huya.common.result.Result;
import com.huya.pojo.entity.PsychologicalTest;
import com.huya.service.PsychologicalTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userPsychologicalTestController")
@RequestMapping("/user/tests")
public class PsychologicalTestController {
    @Autowired
    private PsychologicalTestService psychologicalTestService;

    /**
     * 获取所有测试列表
     * @return
     */
    @GetMapping("/all")
    public Result<List<PsychologicalTest >>getAllTests() {
        List<PsychologicalTest> tests = psychologicalTestService.getAllTests();
        return Result.success(tests);
    }

    /**
     * 根据id获取测试详情
     * @param testId
     * @return
     */
    @GetMapping("/{testId}")
    public Result<PsychologicalTest> getTestById(@PathVariable Long testId) {
        return Result.success(psychologicalTestService.getTestById(testId));
    }
}
